package com.ibangnuo.manage.controller;

import com.ibangnuo.api.PermissionControllerApi;
import com.ibangnuo.framework.domain.Role;
import com.ibangnuo.framework.domain.ext.MenuExt;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.framework.model.response.ResponseResult;
import com.ibangnuo.manage.service.PermissionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author:ly
 * @Data:2020/1/9 14:06
 * @Verdion:1.0
 */
@RestController
@RequestMapping("/permissionsEntity")
public class PermissionController implements PermissionControllerApi {

    @Autowired
    private PermissionService permissionService;

    @Override
    @GetMapping("/permissionsAll")
    public QueryResponseResult findList() {
        return permissionService.findList();
    }

    @Override
    @PostMapping("/upRole")
    public QueryResponseResult upRole(@RequestBody Role role) {
        return permissionService.upRole(role);
    }

    @Override
    @GetMapping("/menuList")
    public QueryResponseResult findMenuList() {
        return permissionService.findMenuList();
    }

    @Override
    @PostMapping("/roleAll")
    public QueryResponseResult findRoleList(@RequestBody Role role) {
        return permissionService.findRoleList(role);
    }

    @PostMapping("/roleById")
    @Override
    public QueryResponseResult editRole(Role  role) {
      return  permissionService.editRole(role);
    }

    @Override
    @GetMapping("/findRoleName")
    public QueryResponseResult findRoleName() {
        return permissionService.findRoleName();
    }

    @Override
    @GetMapping("/roleById/{id}")
    public QueryResponseResult findRole(@PathVariable("id") String id) {
        return permissionService.findRole(id);
    }

    @Override
    @PostMapping("/addRole")
    public QueryResponseResult addRole(@RequestBody Role role) {
        return permissionService.addRole(role);
    }

    @Override
    @GetMapping("/selectMenu/{id}")
    public QueryResponseResult selectMenu(@PathVariable("id") String id) {
        return permissionService.selectMenu(id);
    }

    @Override
    @PostMapping("/edit")
    public QueryResponseResult editMenu(@RequestBody Map map) {
        return permissionService.editMenu(map);
    }

    @Override
    @GetMapping("/delRole/{id}")
    public QueryResponseResult delRole(@PathVariable("id") String id) {
        return permissionService.delRole(id);
    }

    @Override
    @GetMapping("/roleNameAll")
    public QueryResponseResult RoleNameAll() {

        return permissionService.findRoleNameAll();
    }
}
